/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Bussiness;

import DatabaseAccess.DBHelper;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;

/**
 *
 * @author Mrhung
 */
public class ThanhToan {

    private String MaNV;
    private String MaNCC;
    private String SoPhieuChi;
    private String NgayChi;
    private String LyDo;
    private String XacNhan;
    private DBHelper conn = new DBHelper();

    public String getLyDo() {
        return LyDo;
    }

    public void setLyDo(String LyDo) {
        this.LyDo = LyDo;
    }

    public String getMaNCC() {
        return MaNCC;
    }

    public void setMaNCC(String MaNCC) {
        this.MaNCC = MaNCC;
    }

    public String getMaNV() {
        return MaNV;
    }

    public void setMaNV(String MaNV) {
        this.MaNV = MaNV;
    }

    public String getNgayChi() {
        return NgayChi;
    }

    public void setNgayChi(String NgayChi) {
        this.NgayChi = NgayChi;
    }

    public String getSoPhieuChi() {
        return SoPhieuChi;
    }

    public void setSoPhieuChi(String SoPhieuChi) {
        this.SoPhieuChi = SoPhieuChi;
    }

    public String getXacNhan() {
        return XacNhan;
    }

    public void setXacNhan(String XacNhan) {
        this.XacNhan = XacNhan;
    }
    public ThanhToan() {
    }

    public ThanhToan(String MaNV, String MaNCC, String SoPhieuChi, String NgayChi, String LyDo, String XacNhan) {
        this.setMaNV(MaNV);
        this.setMaNCC(MaNCC);
        this.setSoPhieuChi(SoPhieuChi);
        this.setNgayChi(NgayChi);
        this.setLyDo(LyDo);
        this.setXacNhan(XacNhan);
    }

    public int insertThanhToan(ThanhToan a) throws SQLException {
        int i = 0;
        try {
            Vector v = new Vector();
            v.add(a.getMaNV());
            v.add(a.getMaNCC());
            v.add(a.getSoPhieuChi());
            v.add(a.getNgayChi());
            v.add(a.getLyDo());
            v.add(a.getXacNhan());

            i = conn.executeUpdate("sp_InsertThanhToan", v);
        } catch (SQLException ex) {
        }
        return i;
    }

    public int updateThanhToan(ThanhToan a) throws SQLException {
        DBHelper obj = new DBHelper();
        int i = 0;
        try {
            Vector v = new Vector();
            v.add(a.getMaNV());
            v.add(a.getMaNCC());
            v.add(a.getSoPhieuChi());
            v.add(a.getNgayChi());
            v.add(a.getLyDo());
            v.add(a.getXacNhan());
            i = obj.executeUpdate("sp_UpdateThanhToan", v);
        } catch (SQLException ex) {
        }
        return i;
    }

    public int DelThanhToan(String SoPhieuChi) throws SQLException {
        int i = 0;
        try {
            Vector paramList = new Vector();
            paramList.add(SoPhieuChi);
            i = conn.executeUpdate("sp_DelThanhToan", paramList);
        } catch (SQLException sqlex) {
        }
        return i;
    }
    public Vector getAllThanhToan() throws SQLException {
        Vector v = new Vector();
        try {
            ResultSet rs = conn.executeQuery("sp_getAllThanhToan");
            while (rs.next()) {
                ThanhToan b = new ThanhToan();
                b.setMaNV(rs.getString(1));
                b.setMaNCC(rs.getString(2));
                b.setSoPhieuChi(rs.getString(3));
                b.setNgayChi(rs.getString(4));
                b.setLyDo(rs.getString(5));
                b.setXacNhan(rs.getString(6));
                v.add(b);
            }
        } catch (SQLException sqle) {
        }
        return v;
    }
}
